<template>
  <div>
    <div style="text-align: center;">
      <el-image
        v-for="(image, index) in theImageList"
        :key="index"
        style="width: 120px; height: 120px; margin-right: 20px;"
        fit="contain"
        :src="image[urlProp] ? image[urlProp].indexOf('http') >= 0 ? image[urlProp] : resUrl + image[urlProp] : ''"
        :preview-src-list="[image[urlProp] ? image[urlProp].indexOf('http') >= 0 ? image[urlProp] : resUrl + image[urlProp] : '']"
      ></el-image>
    </div>
  </div>
</template>

<script>
import * as auth from '@/utils/auth'
import { doPostJson } from '@/utils/utils'
const resUrl = process.env.VUE_APP_RES_URL

export default {
  name: 'ImageViewer',
  props: {
    imageList: {
      type: Array,
      default: () => [],
    },
    urlProp: {
      type: String,
      default: 'picUrl',
    },
    searchPicUrl: {
      type: String,
      defalut: null,
    },
  },
  data() {
    return {
      resUrl,
      theImageList: this.imageList,
      theSearchPicUrl: this.searchPicUrl,
    }
  },
  computed: {},
  mounted() {},
  methods: {
    initImages(picSearchParams) {
      this.theImageList = []
      doPostJson(this.theSearchPicUrl, picSearchParams, {})
        .then((response) => {
          response.data.rows.forEach((pic) => {
            this.theImageList.push(pic)
          })
        })
        .catch((error) => {})
    },
  },
}
</script>

<style lang="scss">
</style>
